fid = fopen('../../data/in/glass_uncertain.txt', 'r');

[temp1] = fscanf(fid, '%d', [1,2]);
disp([temp1]);
M = temp1(2);
temp1(2) = 2*temp1(2)+1;
data = fscanf(fid, '%lf', [temp1(2), temp1(1)]);
fclose(fid);
data = data';
N = size(data, 1);
label_count = max(data(:, 1));

indices = crossvalind('Kfold',N,10);
prec = zeros(1, 10);

for i = 1:10
    parent = [];
    test = (indices == i); train = ~test;     
    [parent, attrib, split, label_prob] = id3_train(data(train, :), 1:size(train, 1), 3*ones([1, M]), 1, label_count);
    parent = [0, parent];
    prec(i) = id3_data_test(data(test, :), parent, attrib, split, label_prob, label_count);
end    
disp(mean(prec));
